/*
 * Copyright (C) 2009 Georgios J. Georgopoulos, All rights reserved.
 * 
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option) any
 * later version.
 * 
 * This software is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
 * site: http://www.fsf.org.
 */
package org.gwt.mosaic.xul.client.application;

/**
 * A singleton that manages shared objects, like actions, resources, and tasks,
 * for {@code Applications}.
 * <p>
 * {@link Application Applications} use the {@code ApplicationContext} singleton
 * to find global values and services. The majority of the GWT Mosaic
 * Application Framework API can be accessed through the {@code
 * ApplicationContext}. The static {@code #getInstance()} method returns the
 * singleton Typically it's only called after the application has been
 * {@link Application#launch(Application) launched}, however it is always safe
 * to call {@code getInstance()}.
 * 
 * @see Application
 * 
 * @author georgopoulos.georgios(at)gmail.com
 * 
 */
public class ApplicationContext extends org.gwt.mosaic.application.client.ApplicationContext {

  private ElementManager elementManager;

  /**
   * Returns the shared {@code ElementMap} chain for the entire {@code
   * Application}.
   * 
   * @return the {@code ElementMap} chain for the entire {@code Application}.
   * @see ElementManager#getElementMap()
   */
  public final ElementMap getElementMap() {
    if (elementManager == null) {
      elementManager = new ElementManager(this);
    }
    return elementManager.getElementMap();
  }
}
